feat(panel): add hide-reviewed-files mode - #309
Conversation
Allow reviewed files, represented by panel selections, to be hidden so reviewers can focus on the remaining files. Expose toggle_hide_selected with H as the default mapping, filter list and tree views, update section counts, show a hidden-files hint, and adjust navigation when entries disappear from the panel.
Store the hide-reviewed flag alongside file selections in the same repository and revision scope. Restore the flag when opening or retargeting a view, save toggle changes immediately, and treat stores without the field as hide mode disabled.
Cover hide-state serialization, backward-compatible store entries, visible and hidden counts, list filtering, and keymap overrides.
There was a problem hiding this comment.
🔵 Needs a closer look
It is a sizable feature that reworks core file-panel navigation, rendering, and persistence with many interactive edge cases best validated by a human, and only minor nits were found.
Pull request overview
This PR implements the "hide reviewed files" feature requested in issue #307. Building on the existing multi-file selection ("mark reviewed") system, it adds an H mapping and a toggle_hide_selected action that hide/reveal marked (reviewed) files in the diff file panel, letting users focus on the remaining changes. Section counters switch to a visible/total form while hiding is active, a footer hint reports how many files are hidden, and the hide state is persisted per repository/revision alongside the existing selection persistence. Navigation is carefully updated so the diff never lingers on a file that just disappeared.
Changes:
- New
FilePanelstatehide_selectedwith helpers (toggle_hide_selected,count_hidden,count_visible) and filtering inordered_file_list/reconstrain_cursor. - Renderer skips hidden files/empty directories, shows
visible/totalcounters, and renders a "N reviewed file(s) hidden" footer; listeners rewrite the toggle flow withfind_visible_neighborto keep the shown diff and cursor coherent. - Persistence extended to round-trip the hide flag (
selection_store+diff_view), plus new keymap/action registration, docs, and extensive tests.
File summaries
| File | Description |
|---|---|
| lua/diffview/scene/views/diff/file_panel.lua | Adds hide_selected state, filtering in ordered_file_list, and toggle_hide_selected/count_hidden/count_visible; cursor reconstraint when no rows are visible. |
| lua/diffview/scene/views/diff/render.lua | Skips hidden files/dirs, renders visible/total section counters, and adds the hidden-files footer hint. |
| lua/diffview/scene/views/diff/listeners.lua | Rewrites toggle_select_entry and adds toggle_hide_selected with neighbor-finding navigation. |
| lua/diffview/scene/views/diff/diff_view.lua | Loads/saves the hide flag with selections, including across revision-scope changes. |
| lua/diffview/selection_store.lua | Persists and loads the hide flag; keeps scope when hiding with no selections. |
| lua/diffview/config.lua | Registers the H keymap and updates persist_selections docs. |
| lua/diffview/actions.lua | Declares and exposes the toggle_hide_selected action. |
| doc/diffview.txt, doc/diffview_defaults.txt, README.md | Document the new mapping, action, and persistence behavior. |
| lua/diffview/tests/functional/*.lua | Adds tests for store round-trip, panel filtering/counters, navigation, config keymap, and API refresh. |
Review details
- Files reviewed: 16/16 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| local vis_c, tot_c = panel:count_visible("conflicting") | ||
| local count_c = (panel.hide_selected and vis_c < tot_c) and (vis_c .. "/" .. tot_c) | ||
| or tostring(tot_c) |
| eq(1, tot_s) | ||
| end) | ||
|
|
||
| it("count_visible returns 0,0 for an unknown kind", function() |
#307